pkgname=hadoop
pkgver=3.3.1
pkgrel=1
url='https://hadoop.apache.org'
arch=('aarch64' 'x86_64')
license=('Apache License 2.0')
source=("https://mirrors.tuna.tsinghua.edu.cn/apache/hadoop/common/hadoop-$pkgver/hadoop-$pkgver-$arch.tar.gz"
	'core-site.xml'
	'hdfs-site.xml'
	'mapred-site.xml'
	'yarn-site.xml'
	)
md5sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' 'SKIP')

package()
{
	# package jdk
	local jdk_arch
	if [ "$arch" == "aarch64" ]; then
		jdk_arch="aarch64"
	else
		jdk_arch="x64"
	fi
	source $LKP_SRC/lib/http.sh
	# the other url can be used:https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u222-b10/OpenJDK8U-jdk_${jdk_arch}_linux_hotspot_8u222b10.tar.gz
	http_get_file "https://mirrors.tuna.tsinghua.edu.cn/AdoptOpenJDK/9/jdk/${jdk_arch}/linux/OpenJDK9U-jdk_${jdk_arch}_linux_hotspot_9_181.tar.gz" "${srcdir}/jdk.tar.gz"
	mkdir -p "${pkgdir}/usr/local/"
	tar -xzf "${srcdir}/jdk.tar.gz" -C "${pkgdir}/usr/local/"
	mv "${pkgdir}/usr/local/jdk-9+181" "${pkgdir}/usr/local/jdk"

	# package hadoop
	hadoop_home="${pkgdir}/usr/${pkgname}"
	mkdir -p "${hadoop_home}"
	cp -af "${srcdir}/${pkgname}-${pkgver}/"* "${hadoop_home}"

	# package hadoop conf
	hadoop_conf_dir="${hadoop_home}/etc/hadoop"
	mkdir -p "${hadoop_conf_dir}"
	cp core-site.xml "${hadoop_conf_dir}"
	cp hdfs-site.xml "${hadoop_conf_dir}"
	cp mapred-site.xml "${hadoop_conf_dir}"
	cp yarn-site.xml "${hadoop_conf_dir}"
}
